;/*=============================================================================
;#    The element-comm is a tentative program used to test our ideas.           
;#                       Copyright (C)  bgao                                    
;#
;#     This program is free software; you can redistribute it and/or            
;#      modify it under the terms of the GNU General Public License             
;#     as published by the Free Software Foundation; either version 2           
;#         of the License, or (at your option) any later version.               
;#
;#     This program is distributed in the hope that it will be useful,          
;#    but WITHOUT ANY WARRANTY; without even the implied warranty of           
;#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the            
;#             GNU General Public License for more details.                    
;#
;#    You should have received a copy of the GNU General Public License        
;#     along with this program; if not, write to the Free Software             
;#      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,             
;#                       MA  02110-1301, USA.                                  
;#==============================================================================
;# $Id$ 
;#
;# $Author$ 
;#
;# $Revision$ 
;#
;# $Date$ 
;#
;# Description: 
;#
;=============================================================================*/
#include <avr/io.h>


.extern user_int_vector
.extern wsn_thread0_context
.extern wsn_sched_mode
.extern wsn_disable_sched
.extern wsn_int_nesting
.extern wsn_int_sched

WSN_ISR_COMMON:
;save the context
;	PUSH    R30              ;Pushed already
;	PUSH    R31              ;Pushed already
	PUSH    R0               ;Push register on stack
	IN      R0,0x3F          ;In from I/O location
	PUSH    R0               ;Push SREG on stack
	LDS     R0,0x005B        ;Load direct from data space
	PUSH    R0               ;Push RAMPZ on stack
	PUSH    R1               ;Push register on stack
	CLR     R1               ;Clear Register
	PUSH    R18              ;Push register on stack
	PUSH    R19              ;Push register on stack
	PUSH    R20              ;Push register on stack
	PUSH    R21              ;Push register on stack
	PUSH    R22              ;Push register on stack
	PUSH    R23              ;Push register on stack
	PUSH    R24              ;Push register on stack
	PUSH    R25              ;Push register on stack
	PUSH    R26              ;Push register on stack
	PUSH    R27              ;Push register on stack
	PUSH	R28
	PUSH	R29
	LDS     R23, wsn_disable_sched
	PUSH    R23

;**************************************************

	LDS		R20, wsn_int_nesting
	INC		R20
	STS		wsn_int_nesting, R20
	
	CPI     R20, 2
	BRSH    WSN_ISR_START   ; if nested interrupt, no stack check


;check whether need to change to task stack
	LDS  	R19, wsn_sched_mode
	CPI  	R19, 2
 	BRNE 	WSN_ISR_START	;  if in task schedule mode, no stack exchange

;**************************** Change SP begin *****************************
	IN		R28, 0x3D	;SPL
	IN		R29, 0x3E	;SPH
	LDS 	R22, wsn_thread0_context
	LDS 	R21, wsn_thread0_context + 1
	OUT 	_SFR_IO_ADDR(SPH), R22
	OUT 	_SFR_IO_ADDR(SPL), R21
	PUSH 	R29
	PUSH 	R28
;**************************** Change SP end   *****************************

WSN_ISR_START:

;call user interrupt handler

	ICALL		;pc = z-register

;interrupt disable
;	CLI

	LDS		R20, wsn_int_nesting
	DEC		R20
	STS		wsn_int_nesting, R20

	CPI		R20, 0
	BRNE	WSN_ISR_RET


	LDS  	R19, wsn_sched_mode
	CPI  	R19, 2
	BRNE	WSN_ISR_END

;**************************** Restore SP begin *****************************
;	STS		wsn_sched_mode, R19
	POP		R28
	POP		R29
 	IN 		R24, _SFR_IO_ADDR(SPH)
 	IN 		R23, _SFR_IO_ADDR(SPL)

	STS 	wsn_thread0_context, R24
	STS 	wsn_thread0_context+1, R23

	OUT 	_SFR_IO_ADDR(SPH), R29 
	OUT 	_SFR_IO_ADDR(SPL), R28 
;**************************** Restore SP end   *****************************

WSN_ISR_END:
;**************************** Task Schedule Check begin *****************************
	CALL	wsn_int_sched
;**************************** Task Schedule Check end   *****************************


WSN_ISR_RET:
;restore context
;	CLI
	POP     R23
	STS     wsn_disable_sched, R23
	POP		R29
	POP		R28
	POP     R27              ;Pop register from stack
	POP     R26              ;Pop register from stack
	POP     R25              ;Pop register from stack
	POP     R24              ;Pop register from stack
	POP     R23              ;Pop register from stack
	POP     R22              ;Pop register from stack
	POP     R21              ;Pop register from stack
	POP     R20              ;Pop register from stack
	POP     R19              ;Pop register from stack
	POP     R18              ;Pop register from stack
	POP     R1               ;Pop register from stack
	POP     R0               ;Pop register from stack
	STS     0x005B,R0        ;Store direct to data space
	POP     R0               ;Pop register from stack
	OUT     0x3F,R0          ;Out to I/O location
	POP     R0               ;Pop register from stack
	POP     R31              ;Pop register from stack
	POP     R30              ;Pop register from stack
	RETI                     ;Interrupt return

//Interrupt entry

//1************************INT0_vect***********************

.global	INT0_vect
.type	INT0_vect, @function
INT0_vect:
;get user interrupt handler address into Z register
 	PUSH    R0               ;Push register on stack
	IN      R0,0x3F          ;In from I/O location
	PUSH    R0               ;Push SREG on stack
        SEI                      ;interrupt enable       
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 1 * 2)
	LDI		R31, hi8(user_int_vector + 1 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON

//1************************INT1_vect***********************

.global	INT1_vect
.type	INT1_vect, @function
INT1_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 2 * 2)
	LDI		R31, hi8(user_int_vector + 2 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON

//1************************INT2_vect***********************

.global	INT2_vect
.type	INT2_vect, @function
INT2_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 3 * 2)
	LDI		R31, hi8(user_int_vector + 3 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON

//1************************INT3_vect***********************

.global	INT3_vect
.type	INT3_vect, @function
INT3_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 4 * 2)
	LDI		R31, hi8(user_int_vector + 4 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON

//1************************INT4_vect***********************

.global	INT4_vect
.type	INT4_vect, @function
INT4_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 5 * 2)
	LDI		R31, hi8(user_int_vector + 5 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON

//1************************INT5_vect***********************

.global	INT5_vect
.type	INT5_vect, @function
INT5_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 6 * 2)
	LDI		R31, hi8(user_int_vector + 6 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON

//1************************CC2420_FIFOP_vect***********************

.global	INT6_vect
.type	INT6_vect, @function
INT6_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 7 * 2)
	LDI		R31, hi8(user_int_vector + 7 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON

//1************************INT7_vect***********************

.global	INT7_vect
.type	INT7_vect, @function
INT7_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 8 * 2)
	LDI		R31, hi8(user_int_vector + 8 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON

//1************************TIMER2_COMP_vect***********************
.global	TIMER2_COMP_vect
.type	TIMER2_COMP_vect, @function
TIMER2_COMP_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 9 * 2)
	LDI		R31, hi8(user_int_vector + 9 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON

//1************************TIMER2_OVF_vect***********************
.global	TIMER2_OVF_vect
.type	TIMER2_OVF_vect, @function
TIMER2_OVF_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 10 * 2)
	LDI		R31, hi8(user_int_vector + 10 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON

//1************************TIMER1_CAPT_vect***********************
.global	TIMER1_CAPT_vect
.type	TIMER1_CAPT_vect, @function
TIMER1_CAPT_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 11 * 2)
	LDI		R31, hi8(user_int_vector + 11 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON

//1************************TIMER1_COMPA_vect***********************
.global	TIMER1_COMPA_vect
.type	TIMER1_COMPA_vect, @function
TIMER1_COMPA_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 12 * 2)
	LDI		R31, hi8(user_int_vector + 12 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON

//1************************TIMER1_COMPB_vect***********************
.global	TIMER1_COMPB_vect
.type	TIMER1_COMPB_vect, @function
TIMER1_COMPB_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 13 * 2)
	LDI		R31, hi8(user_int_vector + 13 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON

//1************************TIMER1_OVF_vect***********************
.global	TIMER1_OVF_vect
.type	TIMER1_OVF_vect, @function
TIMER1_OVF_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 14 * 2)
	LDI		R31, hi8(user_int_vector + 14 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON


//1************************TIMER0_COMP_vect***********************
.global	TIMER0_COMP_vect
.type	TIMER0_COMP_vect, @function
TIMER0_COMP_vect:
;get user interrupt handler address into Z register
        PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 15 * 2)
	LDI		R31, hi8(user_int_vector + 15 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON

//1************************TIMER0_OVF_vect***********************
.global	TIMER0_OVF_vect
.type	TIMER0_OVF_vect, @function
TIMER0_OVF_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 16 * 2)
	LDI		R31, hi8(user_int_vector + 16 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON

//1************************SPI_STC_vect***********************
.global	SPI_STC_vect
.type	SPI_STC_vect, @function
SPI_STC_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 17 * 2)
	LDI		R31, hi8(user_int_vector + 17 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON

//1************************USART0_RX_vect***********************

.global	USART0_RX_vect
.type	USART0_RX_vect, @function
USART0_RX_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 18 * 2)
	LDI		R31, hi8(user_int_vector + 18 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON


//1************************USART0_UDRE_vect***********************
.global	USART0_UDRE_vect
.type	USART0_UDRE_vect, @function
USART0_UDRE_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 19 * 2)
	LDI		R31, hi8(user_int_vector + 19 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON

//1************************USART0_TX_vect***********************
.global	USART0_TX_vect
.type	USART0_TX_vect, @function
USART0_TX_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 20 * 2)
	LDI		R31, hi8(user_int_vector + 20 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON

//1************************ADC_vect***********************
.global	ADC_vect
.type	ADC_vect, @function
ADC_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 21 * 2)
	LDI		R31, hi8(user_int_vector + 21 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON

//1************************EE_READY_vect***********************
.global	EE_READY_vect
.type	EE_READY_vect, @function
EE_READY_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 22 * 2)
	LDI		R31, hi8(user_int_vector + 22 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON

//1************************ANALOG_COMP_vect***********************

.global	ANALOG_COMP_vect
.type	ANALOG_COMP_vect, @function
ANALOG_COMP_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 23 * 2)
	LDI		R31, hi8(user_int_vector + 23 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON


//1************************TIMER1_COMPC_vect***********************
.global	TIMER1_COMPC_vect
.type	TIMER1_COMPC_vect, @function
TIMER1_COMPC_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 24 * 2)
	LDI		R31, hi8(user_int_vector + 24 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON

//1************************TIMER3_CAPT_vect***********************
.global	TIMER3_CAPT_vect
.type	TIMER3_CAPT_vect, @function
TIMER3_CAPT_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 25 * 2)
	LDI		R31, hi8(user_int_vector + 25 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON

//1************************TIMER3_COMPA_vect***********************
.global	TIMER3_COMPA_vect
.type	TIMER3_COMPA_vect, @function
TIMER3_COMPA_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 26 * 2)
	LDI		R31, hi8(user_int_vector + 26 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON

//1************************TIMER3_COMPB_vect***********************

.global	TIMER3_COMPB_vect
.type	TIMER3_COMPB_vect, @function
TIMER3_COMPB_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 27 * 2)
	LDI		R31, hi8(user_int_vector + 27 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON


//1************************TIMER3_COMPC_vect***********************
.global	TIMER3_COMPC_vect
.type	TIMER3_COMPC_vect, @function
TIMER3_COMPC_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 28 * 2)
	LDI		R31, hi8(user_int_vector + 28 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON

//1************************TIMER3_OVF_vect***********************
.global	TIMER3_OVF_vect
.type	TIMER3_OVF_vect, @function
TIMER3_OVF_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 29 * 2)
	LDI		R31, hi8(user_int_vector + 29 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON

//1************************USART1_RX_vect***********************

.global	USART1_RX_vect
.type	USART1_RX_vect, @function
USART1_RX_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 30 * 2)
	LDI		R31, hi8(user_int_vector + 30 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON


//1************************USART1_UDRE_vect***********************
.global	USART1_UDRE_vect
.type	USART1_UDRE_vect, @function
USART1_UDRE_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 31 * 2)
	LDI		R31, hi8(user_int_vector + 31 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON
//1************************USART1_TX_vect***********************
.global	USART1_TX_vect
.type	USART1_TX_vect, @function
USART1_TX_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 32 * 2)
	LDI		R31, hi8(user_int_vector + 32 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON

//1************************TWI_vect_vect***********************

.global	TWI_vect_vect
.type	TWI_vect_vect, @function
TWI_vect_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 33 * 2)
	LDI		R31, hi8(user_int_vector + 33 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON


//1************************SPM_READY_vect***********************
.global	SPM_READY_vect
.type	SPM_READY_vect, @function
SPM_READY_vect:
;get user interrupt handler address into Z register
	PUSH	R30
	PUSH	R31
	PUSH	R17
	PUSH	R16
	LDI		R30, lo8(user_int_vector + 34 * 2)
	LDI		R31, hi8(user_int_vector + 34 * 2)
	LPM		R16, Z+
	LPM		R17, Z
	MOV		R30, R16
	MOV		R31, R17
	POP		R16
	POP		R17
	JMP		WSN_ISR_COMMON
